﻿using UnityEngine;
using UnityEditor;
using System.IO;

public class VersionsLog : EditorWindow
{
    private Vector2 scrollPos;
    private string versionText = "";

    public static void ShowWindow()
    {
        EditorWindow window = EditorWindow.GetWindow<VersionsLog>();
        window.position = new Rect(100, 100, 500, 400);
        window.titleContent = new GUIContent("版本日志");
        window.Show();
    }

    void Awake()
    {
        using (FileStream fs = new FileStream(Application.dataPath + "/Editor/ReadMe.txt", FileMode.Open))
        {
            using (StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8))
            {
                versionText = sr.ReadToEnd();
            }
        }
    }

    void OnGUI()
    {
        GUILayout.Space(10);
        EditorTools.Label("版本日志", Color.yellow, 20, TextAnchor.MiddleCenter);
        GUILayout.Space(2);
        EditorTools.Label("当前版本：" + CommonTools.Version, Color.green, 12, TextAnchor.MiddleCenter);
        GUILayout.Space(6);

        scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
        {
            GUILayout.TextArea(versionText);
        }
        GUILayout.EndScrollView();
    }
}
